Here I want to apply the projected neighbors graph visualization to the pancreas dataset that is used in the scVelo demo and compare it to the visualization on the U2OS dataset.
Use the reticulate package to use scVelo from within R:
Extract spliced and unspliced data
Extract PCA coordinates
Filter genes
Downsample cells to make things easier
Normalize for dimensional reduction
## Warning in if (!class(counts) %in% c("dgCMatrix", "dgTMatrix")) {: the condition
## has length > 1 and only the first element will be used
## Converting to sparse matrix ...
## Normalizing matrix with 1232 cells and 8724 genes
Dimensional reduction
Run velocyto on panc data
Scores of observed and projected states in PC space
Graph visualization on subset of cells from PC coordinates
Graph visualization on subset of cells from gene expression
using common.genes (intersect of overdispersed genes, odsGenes, and genes in velocity output (genes with high correlation b/w spliced and unspliced))
Effects of changing k, distance measure, similarity measure, and similarity threshold:
Using PC generated graph
L1 vs L2 as distance measure:
#using k=10, similarity=cosine, threshold=0.25
set.seed(1)
graphViz(curr.scores.cellsub,proj.scores.cellsub,10,"L1","cosine",0.25,cell.cols.grph,"L1 distance")
graphViz(curr.scores.cellsub,proj.scores.cellsub,10,"L2","cosine",0.25,cell.cols.grph,"L2 distance")
Pearson correlation vs Cosine similarity:
set.seed(1)
graphViz(curr.scores.cellsub,proj.scores.cellsub,10,"L2","cosine",0.25,cell.cols.grph,"Cosine Similarity")
graphViz(curr.scores.cellsub,proj.scores.cellsub,10,"L2","pearson",-0.5,cell.cols.grph,"Pearson Correlation")
..looks like correlation is more conservative than cosine similarity.
Number of out edges k: